
    import java.util.Random;
    public class test1 {
        public static void main(String[] args) {
            Random random = new Random();
            int maxSum = 105;
            //123
            int maxMinuend = 100;
            int maxSubtrahend = 100;
            int exercisesPerLine = 5;
            for (int i = 1; i <= 50; i++) {
                int num1 = random.nextInt(maxSum + 1);
                int num2 = random.nextInt(maxSum - num1 + 1);
                int num3 = random.nextInt(maxMinuend + 1);
                int num4 = random.nextInt(num3 + 1);
                boolean isAddition = random.nextBoolean();
                int result = isAddition ? num1 + num2 : num3 - num4;
                String operator = isAddition ? "+" : "-";
                System.out.printf("%d.%d %s %d = %d\t", i, isAddition ? num1 : num3, operator, isAddition ? num2 : num4, result);
                if (i % exercisesPerLine == 0) {
                    System.out.println();
                }
            }
        }
    }

